package com;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

import model.Product;

@ManagedBean
@RequestScoped
public class Bookmark {

    @ManagedProperty(value = "#{showProducts}")
    private ShowProducts showProducts;

    public ShowProducts getShowProducts() {
        return showProducts;
    }

    public void setShowProducts(ShowProducts showProducts) {
        this.showProducts = showProducts;
    }

    public String redir() {
        showProducts.setRecent();
        return "details?faces-redirect=true&amp;includeViewParams=true";
    }

    public String simpleRedir() {
        Product p = showProducts.getProductById(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("pname"));
        showProducts.setProduct(p);
        return "details?faces-redirect=true&amp;includeViewParams=true";
    }

}
